package com.ruoyi.web.controller.sys_ksh;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ZhsnOdsIndex;
import com.ruoyi.system.service.IZhsnOdsIndexService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ZhsnOdsIndexController
 * 
 * @author ruoyi
 * @date 2023-12-05
 */
@Controller
@RequestMapping("/system/ZhsnOdsIndex")
public class ZhsnOdsIndexController extends BaseController
{
    private String prefix = "system/ZhsnOdsIndex";

    @Autowired
    private IZhsnOdsIndexService zhsnOdsIndexService;

    @RequiresPermissions("system:ZhsnOdsIndex:view")
    @GetMapping()
    public String ZhsnOdsIndex()
    {
        return prefix + "/ZhsnOdsIndex";
    }

    /**
     * 查询ZhsnOdsIndex列表
     */
    @RequiresPermissions("system:ZhsnOdsIndex:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZhsnOdsIndex zhsnOdsIndex)
    {
        startPage();
//        System.out.println(zhsnOdsIndexService.selectZhsnOdsIndexList(zhsnOdsIndex));
        List<ZhsnOdsIndex> list = zhsnOdsIndexService.selectZhsnOdsIndexList(zhsnOdsIndex);
        return getDataTable(list);
    }




    /**
     * 导出ZhsnOdsIndex列表
     */
    @RequiresPermissions("system:ZhsnOdsIndex:export")
    @Log(title = "ZhsnOdsIndex", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZhsnOdsIndex zhsnOdsIndex)
    {
        List<ZhsnOdsIndex> list = zhsnOdsIndexService.selectZhsnOdsIndexList(zhsnOdsIndex);
        ExcelUtil<ZhsnOdsIndex> util = new ExcelUtil<ZhsnOdsIndex>(ZhsnOdsIndex.class);
        return util.exportExcel(list, "ZhsnOdsIndex数据");
    }

    /**
     * 新增ZhsnOdsIndex
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存ZhsnOdsIndex
     */
    @RequiresPermissions("system:ZhsnOdsIndex:add")
    @Log(title = "ZhsnOdsIndex", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZhsnOdsIndex zhsnOdsIndex)
    {
        return toAjax(zhsnOdsIndexService.insertZhsnOdsIndex(zhsnOdsIndex));
    }

    /**
     * 修改ZhsnOdsIndex
     */
    @RequiresPermissions("system:ZhsnOdsIndex:edit")
    @GetMapping("/edit/{省份}")
    public String edit(@PathVariable("省份") String 省份, ModelMap mmap)
    {
        ZhsnOdsIndex zhsnOdsIndex = zhsnOdsIndexService.selectZhsnOdsIndexBy省份(省份);
        mmap.put("zhsnOdsIndex", zhsnOdsIndex);
        return prefix + "/edit";
    }

    /**
     * 修改保存ZhsnOdsIndex
     */
    @RequiresPermissions("system:ZhsnOdsIndex:edit")
    @Log(title = "ZhsnOdsIndex", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZhsnOdsIndex zhsnOdsIndex)
    {
        return toAjax(zhsnOdsIndexService.updateZhsnOdsIndex(zhsnOdsIndex));
    }

    /**
     * 删除ZhsnOdsIndex
     */
    @RequiresPermissions("system:ZhsnOdsIndex:remove")
    @Log(title = "ZhsnOdsIndex", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zhsnOdsIndexService.deleteZhsnOdsIndexBy省份s(ids));
    }
}
